﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MoviePlaySort.aspx.cs" Inherits="MoviePlaySort" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        body
        {
            font-size: 13px;
            font-family: "Trebuchet MS" , "Helvetica" , "Arial" , "Verdana" , "sans-serif";
        }
        #sortable
        {
            width: 100%;
            float: left;
        }
        #sortable div
        {
            margin-bottom: 5px;
        }
        #sortright
        {
            width: 40%;
            float: right;
        }
        .ui-state-default
        {
            border: 1px solid #d3d3d3;
            background: #e6e6e6 url(ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;
            font-weight: normal;
            color: #555555;
            outline: none;
            text-align: left;
            padding: 4px;
        }
        .ui-state-default span
        {
            padding: 0px 20px 0px 0px;
        }
    </style>
    <link href="../../Content/css/ui-lightness/jquery-ui-1.8.16.custom.css" rel="stylesheet"
        type="text/css" />
    <script src="../../Content/js/jquery-1.6.2.min.js" type="text/javascript"></script>
    <link href="../../Content/Style.css" rel="stylesheet" type="text/css" />
    <script src="../../Content/js/ui.core.js" type="text/javascript"></script>
    <script src="../../Content/js/ui.sortable.js" type="text/javascript"></script>
    <script src="../../Content/js/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
//            getSortPlayList($("#drp_moviePlayList").val());
//            $("#drp_moviePlayList").change(function () {
//                var id = $(this).val();
//                getSortPlayList(id);
//            })
//            $("#btn_save").click(
//				function () {
//				    var a = $("#sortable div span:odd");
//				    var pids = ""; //播放顺序集合
//				    var mids = ""; //影片ID集合
//				    var id = $("#drp_moviePlayList").val();
//				    a.each(function (i) {
//				        pids += (i + 1) + ",";
//				        mids += this.id.replace("item", "") + ",";
//				    });
//				    if (pids == "" || mids == "") {
//				        return;
//				    }
//				    $.post("../../ProgressHandler/Movie/SaveSortPlayList.ashx", { id: id, pids: pids, mids: mids }, function (data) {
//				        if (data == "1") {
//				            alert("保存成功！");
//				        }
//				        else { alert("保存失败！"); }
//				    });
//				}
//		        );
            $("#btn_add").click(function () {
                var horizontalPadding = 30;
                var verticalPadding = 30;
                var id = $("#drp_moviePlayList").val();
                $("<iframe id='externalSite' src='MoviePlaySortAdd.aspx?id=" + id + "' scrolling='no' />").dialog({
                    title: "添加影片至列表",
                    autoOpen: true,
                    width: 650,
                    height: 400,
                    modal: true,
                    resizable: true,
                    autoResize: true,
                    beforeclose: function () { window.location.href = "MoviePlaySort.aspx?id=" + id; },
                    overlay: {
                        opacity: 0.5,
                        background: "black"
                    }
                }).width(650 - horizontalPadding).height(400 - verticalPadding);
            })
        })
        // 
//        function getSortPlayList(Id) {
//            var cc = "";
//            var timesmap = Date.parse(new Date());
//            $.getJSON("../../ProgressHandler/Movie/GetSortPlayList.ashx?id=" + Id + "&time=" + timesmap, function (data) {
//                $.each(data, function (i, n) {
//                    cc += "<div class='ui-state-default'><span style='float:left'></span>" +
//                    "<span width='25%' id='item" + n.ID + "' name='Item " + n.ID + "'>" + n.MoveName + "&nbsp;&nbsp;&nbsp;" + n.FileName + "&nbsp;&nbsp;&nbsp;" + n.CreateDate + "<a style='padding:0px 0px 0px 100px' href='javascript:void(0)' onclick='del(" + n.ID + ")'>删除</a></span>" +
//                    "</div>";
//                })
//                $("#sortable").html(cc);
//                $("#sortable").sortable();
//            });
//        }
//        //del
//        function del(mid) {
//            var id = $("#drp_moviePlayList").val();
//            $.getJSON("../../ProgressHandler/Movie/DelSortPlayList.ashx?id=" + id + "&mid=" + mid, function (data) {
//                if (data == "1") {
//                    getSortPlayList(id);
//                }
//                else { alert("删除失败！"); }

//            });

//        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td height="30">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="15" height="30">
                                <img src="/Content/images/tab/tab_03.gif" width="15" height="30" />
                            </td>
                            <td width="1101" background="/Content/images/tab/tab_05.gif">
                                <img src="/Content/images/tab/311.gif" width="16" height="16" />
                                <span class="STYLE4">影片管理</span>
                            </td>
                            <td width="281" background="/Content/images/tab/tab_05.gif">
                                &nbsp;
                            </td>
                            <td width="14">
                                <img src="/Content/images/tab/tab_07.gif" width="14" height="30" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td style="margin: 4px 0px 4px 0px">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="9" background="/Content/images/tab/tab_12.gif">
                                &nbsp;
                            </td>
                            <td width="8%">
                                列表名称:
                            </td>
                            <td width="8%">
                                <asp:DropDownList ID="drp_moviePlayList" runat="server">
                                </asp:DropDownList>
                            </td>
                            <td>
                                &nbsp;
                                <input id="btn_save" type="button" value="保存列表"><input type="button" value="添加影片"
                                    id="btn_add" /><div id="itemList">
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td width="9" background="/Content/images/tab/tab_16.gif">
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    <table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="9" background="/Content/images/tab/tab_12.gif">
                                &nbsp;
                            </td>
                            <td>
                                <asp:GridView ID="Grid_Movie" runat="server" AutoGenerateColumns="False" CellPadding="4"
                                    EnableModelValidation="True" ForeColor="#333333" GridLines="None" Width="100%"
                                    OnRowDataBound="Grid_Movie_RowDataBound" AllowSorting="True" OnPageIndexChanging="Grid_Movie_PageIndexChanging"
                                    PageSize="20" onrowediting="Grid_Movie_RowEditing" 
                                    onrowcancelingedit="Grid_Movie_RowCancelingEdit" 
                                    onrowdeleting="Grid_Movie_RowDeleting" onrowupdating="Grid_Movie_RowUpdating">
                                    <AlternatingRowStyle BackColor="White" />
                                    <RowStyle HorizontalAlign="Center" />
                                    <Columns>
                                        <asp:BoundField DataField="PlayIndex" HeaderStyle-Width="50px" FooterText="排序号" HeaderText="排序号">
                                            <HeaderStyle Width="40px"></HeaderStyle>
                                        </asp:BoundField>
                                        <asp:BoundField DataField="MoveName" ReadOnly="true" FooterText="影片名称" HeaderText="影片名称" />
                                        <asp:BoundField DataField="FileName" ReadOnly="true" FooterText="文件名称" HeaderText="文件名称" />
                                        <asp:BoundField DataField="Size" ReadOnly="true" FooterText="文件大小" HeaderText="文件大小" />
                                        <asp:BoundField DataField="TimeLength" ReadOnly="true" FooterText="文件时长" HeaderText="文件时长" />
                                        <asp:BoundField DataField="CreateDate" ReadOnly="true" FooterText="上传日期" DataFormatString="{0:yyyy-MM-dd}"
                                            HeaderText="上传日期" />
                                        <asp:CommandField ShowEditButton="True" />
                                        <asp:CommandField ShowDeleteButton="True" />
                                    </Columns>
                                    <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                                    <HeaderStyle BackColor="#cae1ac" Font-Bold="True" ForeColor="White" />
                                    <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
                                    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                                    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                                </asp:GridView>
                            </td>
                            <td width="9" background="/Content/images/tab/tab_16.gif">
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td height="29">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="15" height="29">
                                <img src="/Content/images/tab/tab_20.gif" width="15" height="29" />
                            </td>
                            <td background="/Content/images/tab/tab_21.gif">
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td width="25%" height="29" nowrap="nowrap">
                                        </td>
                                        <td width="75%" valign="top" class="STYLE1">
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td width="14">
                                <img src="/Content/images/tab/tab_22.gif" width="14" height="29" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
